package com.atguigu.springmvc.demo01.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author yanglin
 * @create 2023-12-14 14:27 星期四
 * description:
 */
@Controller
//@RequestMapping("/hello")
public class RequestMappingController {

    /**
     * @RequestMapping
     *  value的值是一个数组
     *  value = {"/testRequestMapping","/test"}: 表示该方法能够处理多个请求
     *  method:设置方法的请求方式 （要在value属性的基础上）
     * @return
     */
    @RequestMapping(
            value = {"/testRequestMapping","/test"},
            method = {RequestMethod.POST,RequestMethod.GET},
//            params = {"!username"}
            params = {"username","password=123456"},    //两个条件必须同时满足
//            params = {"username=admin"}
//            params = {"username!=admin"}
            headers = {"Host=localhost:8080"}
//            headers = {"!header"},
//            headers = {"header=admin"},
//            headers = {"header!=admin"},
    )
    public String success(){
        return "success";
    }
    
    @RequestMapping(value = "/testPut",method = RequestMethod.PUT)
    public String testPut(){
        return "success";
    }

    /**
     * ant风格的路径  
     *  a?a：?可以代表任意单个字符
     *  a*a: *表示0个或多个字符
     *  **: 表示任意一层或多层目录
     * @return
     */
//    @RequestMapping("/a?a/testAnt")
//    @RequestMapping("/a*a/testAnt")
    @RequestMapping("/**/testAnt")
    public String testAnt(){
        return "success";
    }
    
    @RequestMapping("/testPath/{id}")
    public String testPath(@PathVariable("id") Integer id){
        System.out.println(id);
        return "success";
    }
    
}
